package com.zx.utils;

import javax.servlet.http.HttpServletRequest;

import com.zx.map.service.AgentInfoService;
import com.zx.map.service.model.AgentInfoModel;
import com.zx.platform.context.ApplicationContextUtil;
import com.zx.platform.service.domain.ManageSessionDomain;
import com.zx.platform.service.model.OperatorInfoModel;

public class WebUtils {

	/**
	 * 获取当前登录的用户，代理商信息
	 * @param request
	 * @param agentInfoService
	 * @return
	 */
	@Deprecated
	public static AgentInfoModel queryCurrentLoginAgentInfo(HttpServletRequest request,AgentInfoService agentInfoService){
		OperatorInfoModel curOperatorInfo = queryCurrentLoginInfo(request);
        AgentInfoModel curAgentInfoModel = agentInfoService.getAgentInfoModelBySysAccount(curOperatorInfo.getLoginName());
        return curAgentInfoModel;
	}

	/**
	 * 获取当前登录的用户，代理商信息
	 * @param request
	 * @param agentInfoService
	 * @return
	 */
	public static AgentInfoModel queryCurrentLoginAgentInfo(HttpServletRequest request){
		OperatorInfoModel curOperatorInfo = queryCurrentLoginInfo(request);
		AgentInfoService agentInfoService = (AgentInfoService) ApplicationContextUtil.getContext().getBean("agentInfoService");
		AgentInfoModel curAgentInfoModel = agentInfoService.getAgentInfoModelBySysAccount(curOperatorInfo.getLoginName());
		return curAgentInfoModel;
	}
	/**
	 * 获取当前登录用户的信息
	 * @param request
	 * @return
	 */
	public static OperatorInfoModel queryCurrentLoginInfo(HttpServletRequest request){
		ManageSessionDomain userinfo = (ManageSessionDomain) request.getSession().getAttribute("_LOGONUSER_");
		OperatorInfoModel curOperatorInfo = userinfo.getOperatorInfoModel();
        return curOperatorInfo;
	}
}
